package com.xyre.client.business.index.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.xyre.client.R;

/**
 * note
 *
 * @author 741425192@qq.com 2016年02月29日
 */
public class SplashActivity extends Activity {

    private Handler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(initView());

        // 延迟3秒定时
        handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                Intent intent = new Intent(SplashActivity.this, GuidesActivity.class);
                startActivity(intent);
                if (handler != null) {
                    handler.removeCallbacksAndMessages(null);
                }
                handler = null;
                finish();
            }
        }, 3000);


    }

    private ImageView initView() {

        ImageView view = new ImageView(this);
        view.setLayoutParams(new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        view.setImageResource(R.mipmap.begin_logo);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        return view;
    }
}
